package com.apartment.own.mapper;

import com.apartment.common.utils.mp.SelectBuilder;
import com.apartment.own.response.res.HouseSelectResponse;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

public interface CommonMapper {
    /**
     * des.
     * 主表 own_res_house_resource resource
     * 从表 own_res_house_room_conf room  关系 resource.id = room.key_resource_id
     * 返回 list
     * @author       : RazaJin
     * @date         : 2020/9/8 0008 下午 2:02
     */
    @Select("select resource.housing_estate ,resource.id ,resource.no ,resource.unit ,resource.house_no ,resource.end_bed_room ,resource.end_drawing_room ,resource.end_rest_room ,resource.area ,resource.end_build_orientation ,room.norm_amount ,room.low_amount ,room.room_name,room.id as roomId ,room.room_no as roomNo from own_res_house_resource  resource inner join own_res_house_room_conf room on resource.id = room.key_resource_id ${ew.customSqlSegment}")
    List<HouseSelectResponse> listHouseAndRoom(@Param(Constants.WRAPPER) Wrapper wrapper);
    /**
     * des.
     * own_res_house_resource house
     * own_res_property_fee fee
     * own_res_house_contract contract
     * @author       : RazaJin
     * @date         : 2020/9/9 0009 下午 6:01
     */
    @Select("select item, pay_type, radix, balance, account_no, foreign_id from own_res_house_resource house inner join own_res_house_contract contract on contract.key_house_resource_id = house.id inner join own_res_property_fee fee on fee.foreign_id = contract.id  ${ew.customSqlSegment}  ")
    List<Map> listHouseAndFee(@Param(Constants.WRAPPER) Wrapper wrapper);

    /**
     * des.
     * own_res_house_resource house
     * own_res_house_contract contract
     * @author       : RazaJin
     * @date         : 2020/9/9 0009 下午 6:01
     */
    @Select("select ${sb.toSql} from own_res_house_resource house inner join own_res_house_contract contract on contract.key_house_resource_id = house.id ${ew.customSqlSegment}")
    List<Map> listHouseAndFeeSelectBuilder(@Param("sb") SelectBuilder selectBuilder, @Param(Constants.WRAPPER) Wrapper wrapper);


    /**
     * des.
     * own_res_house_resource house
     * own_res_article_inventory inventory
     * @author       : RazaJin
     * @date         : 2020/9/9 0009 下午 6:01
     */
    @Select("select items_id, items_name, items_univalent, brand, annex, quantity, items_type, foreign_id, surface_name from own_res_house_resource house inner join own_res_article_inventory inventory on inventory.foreign_id = house.id  ${ew.customSqlSegment} ")
    List<Map> listHouseAndInventory(@Param(Constants.WRAPPER) Wrapper wrapper);
}
